const path = require('path')
const HtmlWebPackPlugin = require('html-webpack-plugin');
module.exports = {
    entry: path.resolve(__dirname, './devmain.js'),
    output: {
        path: path.resolve(__dirname, './build/lib'),
        filename: 'main.js',
        libraryTarget: 'umd',
    },
    module: {
        rules: [
            {
                test: /\.jsx?$|.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        babelrc: false,
                        presets: [
                            require.resolve('@babel/preset-react'), [require.resolve('@babel/preset-env'), { modules: false }]
                        ],
                        cacheDirectory: true
                    },
                }
            },
            {
                test: /\.js$|\.js$/,
                enforce: 'pre',
                use: ['source-map-loader'],
            },
            {
                test: /\.css$/,
                use: [{ loader: 'style-loader', options: {} }, 'css-loader'],
            }
        ]
    },
    devServer: {
        contentBase: path.resolve(__dirname, './build/lib'),
        compress: true,
        port: 9000,
        open: true,
        historyApiFallback: true,
    },
    plugins: [
        new HtmlWebPackPlugin({
            template: 'public/index.html',
            filename: 'index.html',
            inject: true,
        })
    ],
    ignoreWarnings: [/Failed to parse source map/]
}
